<template>
	<view class="flex-col h-max">
		<view class="background" >
			<u-navbar :custom-back="$navBack" is-back backIconColor="#fff" titleColor="#fff" :border-bottom="false"
				title="服务设置" title-bold :is-fixed="false" :background="{background:'#fff0'}">
			</u-navbar>
			<view class="p20 flex w-max">
				<view class="fs26 color-fff " @click="$u.route('/pages/index/chooseAddress/chooseAddress')">
					{{myAdd.name||'请选择'}}
				</view>
				<image src="/static/img/index/arr.png" class="h14 w14 ml10 mr20" mode=""></image>
				<u-search placeholder="输入名称筛选医院" height="72" bg-color="#fff" class="flex1 " :show-action="false"
					:search-icon-color="$zs" disabled @click="">
				</u-search>
			</view>
		</view>
		<view class="flex flex1 ">
			<scroll-view scroll-y class="w40p h-max bg-f5f color-999" style="height: 100%;">
				<view class="flex row-center ov-h p20 relative" :class="{'bg-fff color-333 fw-w':current==index}"
					@click="current=index" v-for="(item,index) in list" :key="index">
					{{item.name}}
					<view class="absolute top0 right0" v-if="item.service.some(e=>e.status==1)">
						<image src="/static/img/icon/sel1.png" class="w20 h20" mode=""></image>
					</view>
				</view>
			</scroll-view>
			<scroll-view scroll-y class="flex1 h-max bg-fff" style="height: 100%;">
				<block v-for="(item,index) in list" :key="index">
					<view class="pl20 pr20" v-if="current==index">
						<view class="flex pt32 pb32 border-b" @click="serviceSet(item1)"
							v-for="(item1,index1) in item.service" :key="index1">
							<view class="color-666 flex1">
								<text>{{item1.name}}</text>
							</view>
							<view class="w36 h36">
								<image src="/static/img/icon/sel1.png" v-if="item1.status==1" class="wh-max" mode="" />
								<image src="/static/img/icon/sel0.png" v-else class="wh-max" mode=""></image>
							</view>
						</view>
					</view>
				</block>
			</scroll-view>
		</view>
		<view class="h120"></view>
		<view class="pf bottom0 left0  w-max flex">
			<!-- <view class="p24 flex1">
				<u-button type="warning" plain ripple @click="$navBack()">取消</u-button>
			</view> -->
			<view class="p24 flex1">
				<u-button type="warning" ripple @click="$navBack()">确认</u-button>
			</view>
		</view>

		<u-popup v-model="show" mode="center" borderRadius="20" width="660">
			<view class="bg-fff radius12 pl20 pr20">
				<view class="flex pt32 pb32 border-b">
					<view class="color-666 flex1">
						<text>是否开启服务</text>
					</view>
					<switch class="scale7" :checked="itemData.status==1"
						@change="e=>itemData.status=e.detail.value*1" :color="$zs" />
				</view>
				<view class="flex pt32 pb32 border-b">
					<view class="color-666 ">陪诊医院</view>
					<input class="tr flex1 " placeholder="陪诊医院" disabled :value="itemData.hospital" />
				</view>
				<view class="flex pt32 pb32 border-b">
					<view class="color-666 mr20">陪诊项目</view>
					<input class="tr flex1" placeholder="陪诊项目" disabled :value="itemData.service" />
				</view>
				<view class="flex pt32 pb32 border-b">
					<view class="color-666 flex1">报价价格</view>
					<view class="bg-f8f w200 h64 flex">
						<input class="tc flex1" v-model="itemData.minimum_price" type="number" placeholder="最低报价" />
					</view>
					<view class="pl28 pr28">-</view>
					<view class="bg-f8f w200 h64 flex">
						<input class="tc flex1" v-model="itemData.highest_price" type="number" placeholder="最高报价" />
					</view>
				</view>
				<view class="flex pt32 pb32 border-b">
					<view class="color-666 flex1">
						<text>一口价价格</text>
					</view>
					<input class="tr flex1" v-model="itemData.price" placeholder="请输入一口价价格" type="number" />
				</view>
				<view class="flex pt32 pb32 border-b">
					<view class="color-666 flex1">
						<text class="color-red">*</text>
						<text>平台建议价：</text>
						<text class="color-red">￥{{itemData.suggested_price||'0.00'}}</text>
					</view>
				</view>
				<!-- 	<view class="flex pt32 pb32 border-b">
					<view class="color-666 flex1">
						<text>是否接受一口价最低金额</text>
					</view>
					<switch class="scale7" :checked="itemData.is_accept==1"
						@change="e=>itemData.is_accept=e.detail.value*1" :color="$zs" />
				</view>
				<view class="flex pt32 pb32 border-b" v-if="itemData.is_accept==1">
					<view class="color-666 flex1">
						<text>一口价最低价</text>
					</view>
					<input class="tr flex1" v-model="itemData.floor_price" placeholder="请输入一口价最低价" />
				</view> -->
				<view class="p24 flex1">
					<u-button type="warning" ripple @click="serviceEdit()">确认</u-button>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				current: 0,
				myAdd: this.$getCache('myAdd') || '',

				show: false,
				itemData: '',
			};
		},
		onLoad(e) {

		},
		onShow() {
			this.myAdd = this.$getCache('myAdd') || ''
			this.getHospital()
		},
		methods: {
			serviceSet(item) { //获取服务设置
				this.$request('/master/my/serviceSet', item).then(res => {
					this.itemData = res.data
					this.show = true
				})
			},
			serviceEdit() { //编辑服务设置
				let params = this.itemData||''
				this.$request('/master/my/serviceEdit', params).then(res => {
					// this.$msg()
					this.show = false
					this.getHospital()
				})
			},
			getHospital() { //获取医院项目列表
				let params = {
					city_id: this.myAdd.id
				}
				if (!params.city_id) return this.$msg('请选择地址')
				this.$request('/master/commom/getHospital', params).then(res => {
					this.list = res.data
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		height: 100%;
		background: #fff;
	}

	.tab-active::before {
		content: "";
		position: absolute;
		border-left: 4px solid $zs;
		height: 40%;
		left: 0;
		// top: 39rpx;
		top: 50%;
		transform: translateY(-50%);
	}
</style>
